package br.com.vti.sisp_sicrim.controller;

import java.util.Arrays;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.Validator;
import br.com.crud4j.core.model.business.Business;
import br.com.crud4j.core.util.MessageResolver;
import br.com.crud4j.vraptor3.controller.ControllerImpl;
import br.com.vti.sisp_sicrim.model.entity.PerfilUsuario;
import br.com.vti.sisp_sicrim.model.entity.Usuario;
import br.com.vti.sisp_sicrim.model.entity.enums.Status;
import br.com.vti.sisp_sicrim.modelo.business.exception.PerfilUsuarioException;
import br.com.vti.sisp_sicrim.modelo.business.exception.UsuarioException;

@Resource
@Path("/pages/usuario")
public class UsuarioController extends ControllerImpl<Usuario, UsuarioException> {

    private final Business<PerfilUsuario, PerfilUsuarioException> perfilUsuarioBusiness;

    @Autowired
    public UsuarioController(@Qualifier("perfilUsuarioBusiness") Business<PerfilUsuario, PerfilUsuarioException> perfilUsuarioBusiness, Result result, Validator validator, @Qualifier("usuarioBusiness") Business<Usuario, UsuarioException> entidadeBusiness, MessageResolver messageResolver) {
        super(result, validator, entidadeBusiness, messageResolver);
        this.perfilUsuarioBusiness = perfilUsuarioBusiness;
    }

    protected Business<PerfilUsuario, PerfilUsuarioException> getPerfilUsuarioBusiness() {
		return perfilUsuarioBusiness;
	}

    
    @Override
    public void salvar(Usuario entidade) {
    	// TODO Auto-generated method stub
    	super.salvar(entidade);
    }

	@PostConstruct
    protected void limpar() {
//        include("sexoList", Arrays.asList(Sexo.values()));
        include("perfilUsuarioList", getPerfilUsuarioBusiness().listar(null));
        include("statusList", Arrays.asList(Status.values()));
    }

}
